#ifndef __CUSTOM_MODBUS_TCP_H__
#define __CUSTOM_MODBUS_TCP_H__

#include <modbus/modbus.h>

#define MODBUS_CUSTOM_FC_TransRealtimeWave  0x64
#define MODBUS_CUSTOM_FC_TransLog	        0x66
#define MODBUS_CUSTOM_FC_FirmwareUpgrade	0x67
#define MODBUS_CUSTOM_FC_FC_TransErrorlog	0x6F
#define MODBUS_CUSTOM_FC_OperatePAC	        0x6E

typedef unsigned char uint8_t;
typedef unsigned short uint16_t;

typedef int (*response_callback)(modbus_t *ctx, uint8_t *req, uint8_t* rsp);

void process_request(modbus_t *ctx,uint8_t *req ,uint8_t *rsp, response_callback callback);

int operatePAC_handle_response(modbus_t *ctx, uint8_t *req ,uint8_t *rsp);

int realtime_wave_handle_response(modbus_t *ctx, uint8_t *req ,uint8_t *rsp);

int PACTable_ReadAll(uint8_t* pBuff);

int handle_client_request(modbus_t *ctx, uint8_t *req, int req_length);

void* customModbus_server1_thread(void* arg);

void* customModbus_server2_thread(void* arg);

int create_customServer_connect(const char* server_ip, int port);

int create_realtimeWaveDataServer_connect(const char* server_ip, int port);

#endif